import { Operations } from "./Operations";
import { RemoveTextOperation } from "./index";
export class InsertTextOperation extends Operations {
  constructor(spacers, insertIndex) {
    super();
    this.spacers_ = spacers;
    this.insertIndex_ = insertIndex;
    this.type = "InsertOpt";
  }
  getSpacers() {
    return this.spacers_;
  }
  setSpacers(spacers) {
    this.spacers_ = spacers;
  }
  apply(editor) {
    editor.getTextModel().insert(this.insertIndex_, this.spacers_);
  }
  reverse() {
    return new RemoveTextOperation(
      this.insertIndex_,
      this.insertIndex_ + this.spacers_.length
    );
  }
  merge(op) {
    return new InsertTextOperation(
      `${op.spacers_ + this.spacers_}`,
      op.insertIndex_
    );
  }
}
export default InsertTextOperation;
